<template>
      <div id="admin_app">
        <el-table
        :data="adminList"
        style="width: 100%">
        <el-table-column
          prop="id"
          label="id"
          min-width="180">
        </el-table-column>
        <el-table-column
          prop="username"
          label="账号"
          min-width="180">
        </el-table-column>
        <el-table-column
          prop="roleid"
          label="角色"
          min-width="180">
        </el-table-column>
        <el-table-column
          prop="status"
          label="状态"
          min-width="180" v-slot="props">
          <template>
              <el-button v-if="props.row.status == 1" type="success" size='mini' plain>正常</el-button>
              <el-button v-else type="danger"  size='mini' plain>禁用</el-button>
          </template>  
        </el-table-column>
        <el-table-column
          label="操作"
          min-width="180" v-slot="props">
          <template>
            <el-button @click="editAdmin(props.row)" type="success" icon="el-icon-edit" size="mini" circle></el-button>
            <el-button @click="delAdmin(props.row.uid)" type="danger" icon="el-icon-delete" size="mini" circle></el-button>
          </template>  
        </el-table-column>
      </el-table>
      <el-pagination
        ref="pagination"
        background
        layout="prev, pager, next"
        :page-size = "size"
        prev-text	= "上一页"
        next-text	= "下一页"
        :total="total"
        @current-change = "changePage"
        >
      </el-pagination>
      </div>  
</template>

<script>
import vm from "../../vm/vm"
export default {
    props: ["adminList","size","total"],
    data() {
        return {
          page:0
        }
    },
    created(){
    },
    methods: {
      delAdmin(id){
         this.$http.post("/userdelete",{uid:id}).then(
        res=>{
           this.$emit("sendPage",this.page)
        }
         )
      },
      changePage(page){
        this.page=page
        this.$emit("sendPage",page)
      },
      editAdmin(row){
        vm.$emit("editAdmin",row)
       
      }
    }
    
}
</script>

<style>

</style>